package com.gzx.bi.modular.goals.monthly.mapper;

import com.gzx.bi.modular.goals.monthly.entity.GzxMonthlyGoals;
import com.gzx.bi.modular.goals.monthly.entity.vo.GzxMonthlyGoalsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import vip.xiaonuo.common.mapper.BaseMapperPlus;

import java.math.BigDecimal;

/**
 * @author zjt
 * @description
 * @since 2025/1/13 14:00
 */
public interface GzxMonthlyGoalsMapper extends BaseMapperPlus<GzxMonthlyGoals, GzxMonthlyGoalsVo> {
    /**
     * 更新指定 ID 的 gzx_monthly_goals 记录的 advance_payment_amount 字段。
     *
     * @param id                   要更新的记录的主键 ID
     * @param advancePaymentAmount 新的 advance_payment_amount 值
     */
    @Update("UPDATE gzx_monthly_goals SET advance_payment = #{advancePaymentAmount} WHERE id = #{id}")
    void updateAdvancePaymentAmount(@Param("id") Long id, @Param("advancePaymentAmount") BigDecimal advancePaymentAmount);

    /**
     * 初始化指定月份的 gzx_monthly_goals 记录的 monthly_achievement_amount 和 detail_json 字段。
     * @param belongMonth 归属月份
     */
    @Update("UPDATE gzx_monthly_goals SET monthly_achievement_amount = 0.00,detail_json = null WHERE belonging_month = #{belongMonth}")
    void updateInit(@Param("belongMonth") String belongMonth);
}
